#include <iostream>
#include "../head/DenseGraph.h"
#include "../head/SparseGraph.h"
#include <string>

using namespace std;

void testGraph();
void testGraph2();
void countCharacter();

int main(){
	// countCharacter();
	// testGraph();
	testGraph2();
}

void countCharacter(){
	char character[10], ch;
	string sentence;
	int i = 0;
	cout << "Please input the character \n";
	cin.getline(character, 10);
	cout << "Please input your sentence \n";
	// cin.getline(sentence, 50);
	for(;ch != '#';){
		sentence += ch;
		cin.get(ch);
		++i;
	}

	cout << character << "\t" << sentence << endl;
}

void testGraph(){
	// 生成20节点 100条边图
	int N = 20;
	int M = 100;
	srand(time(NULL));

	// Sparse Graph O(E) 有多少边遍历多少次
	SparseGraph g1(N, false);	// 每次随机ab两个节点组成边添加进图
	for(int i = 0 ; i < M ; i ++){
		int a = rand()%N;
		int b = rand()%N;
		g1.addEdge(a,b);
	}

	// 遍历所有的节点, 生成 g1相对 节点v的迭代器
	for(int v = 0 ; v < N ; v ++){
		cout << v << " : ";
		SparseGraph::adjIterator adj(g1, v);
		// 迭代过程
		for(int w = adj.begin() ; !adj.end() ; w = adj.next()){
			cout << w << " ";
		}
		cout << endl;
	}
	cout << endl;
}

void testGraph2(){
	// 生成20节点 100条边图
	int N = 20;
	int M = 100;
	srand(time(NULL));

	// Dense Graph  O(V^2)
	DenseGraph g1(N, false);	// 每次随机ab两个节点组成边添加进图
	for(int i = 0 ; i < M ; i ++){
		int a = rand()%N;
		int b = rand()%N;
		g1.addEdge(a,b);
	}

	// 遍历所有的节点, 生成 g1相对 节点v的迭代器
	for(int v = 0 ; v < N ; v ++){
		cout << v << " : ";
		DenseGraph::adjIterator adj(g1, v);
		// 迭代过程
		for(int w = adj.begin() ; !adj.end() ; w = adj.next()){
			cout << w << " ";
		}
		cout << endl;
	}
	cout << endl;
}
